<template>
  <div id="app">
    <el-container>
      <!-- 头部 -->
      <el-header class="app-header">
        <div class="header-content">
          <div class="logo">
            <el-icon size="24"><Document /></el-icon>
            <span class="logo-text">杜伊斯堡签证预约平台</span>
          </div>
          <div class="nav">
            <div class="nav-buttons">
              <el-button type="primary" @click="$router.push({ name: 'Home' })" size="small">首页</el-button>
              <el-button @click="$router.push({ name: 'Status' })" size="small">查询状态</el-button>
            </div>
            <div v-if="isAdminAuthenticated" class="admin-buttons">
              <el-button 
                @click="$router.push({ name: 'QueueManagement' })"
                size="small"
              >
                队列管理
              </el-button>
              <el-button 
                @click="$router.push({ name: 'Debug' })"
                size="small"
              >
                调试
              </el-button>
              <el-button 
                type="success" 
                @click="$router.push({ name: 'AdminPanel' })"
                size="small"
              >
                管理面板
              </el-button>
            </div>
          </div>
        </div>
      </el-header>

      <!-- 主要内容 -->
      <el-main class="app-main">
        <router-view />
      </el-main>

      <!-- 底部 -->
      <el-footer class="app-footer">
        <div class="footer-content">
          <p>&copy; 2024 杜伊斯堡签证预约平台. 所有权利保留.</p>
        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script>
import { ref, onMounted } from 'vue'
import { Document } from '@element-plus/icons-vue'
import { checkAdminAuth } from './utils/auth'

export default {
  name: 'App',
  components: {
    Document
  },
  setup() {
    const isAdminAuthenticated = ref(false)
    
    onMounted(() => {
      // 延迟检查认证状态，确保auth模块已初始化
      setTimeout(() => {
        try {
          isAdminAuthenticated.value = checkAdminAuth()
        } catch (error) {
          console.error('检查管理员认证状态失败:', error)
          isAdminAuthenticated.value = false
        }
      }, 200)
    })
    
    return {
      isAdminAuthenticated
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#app {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.app-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: bold;
  color: #333;
}

.nav {
  display: flex;
  gap: 10px;
  flex-direction: row;
  align-items: center;
}

.nav-buttons, .admin-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.app-main {
  padding: 20px;
  min-height: calc(100vh - 120px);
}

.app-footer {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer-content {
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  max-width: 1200px;
  margin: 0 auto;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 12px;
    padding: 12px 15px;
    height: auto;
    min-height: 80px;
  }
  
  .logo {
    justify-content: center;
  }
  
  .logo-text {
    font-size: 18px;
  }
  
  .nav {
    width: 100%;
    gap: 12px;
    flex-direction: column;
    align-items: center;
  }
  
  .nav-buttons, .admin-buttons {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  
  .nav .el-button {
    font-size: 13px;
    padding: 8px 16px;
    min-width: 90px;
    flex: 0 0 auto;
    border-radius: 20px;
    font-weight: 500;
  }
  
  .app-main {
    padding: 15px;
    min-height: calc(100vh - 140px);
  }
  
  .app-footer {
    padding: 10px;
  }
  
  .footer-content {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 10px 12px;
    gap: 10px;
  }
  
  .logo-text {
    font-size: 16px;
  }
  
  .nav {
    gap: 10px;
  }
  
  .nav-buttons, .admin-buttons {
    gap: 6px;
  }
  
  .nav .el-button {
    font-size: 12px;
    padding: 6px 12px;
    min-width: 80px;
    border-radius: 18px;
  }
  
  .app-main {
    padding: 10px;
  }
}
</style>


